// BroadCast.cpp : implementation file
//

#include "stdafx.h"
#include "chat_admin.h"
#include "BroadCast.h"
#include "afxdialogex.h"
#include "ChatClient.h"
#include "json.h"

// BroadCast dialog

IMPLEMENT_DYNAMIC(BroadCast, CDialogEx)

BroadCast::BroadCast(CWnd* pParent /*=NULL*/)
	: CDialogEx(BroadCast::IDD, pParent)
{

}

BroadCast::~BroadCast()
{
}
 void BroadCast::OnOK()
{
	//CDialogEx::OnOK();
}

void BroadCast::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_BROAD, mBroad);   
	DDX_Text(pDX,IDC_BROAD,mBroadStr);
}


BEGIN_MESSAGE_MAP(BroadCast, CDialogEx)
	ON_BN_CLICKED(IDC_SEND_BROAD, &BroadCast::OnBnClickedSendBroad)

END_MESSAGE_MAP()


// BroadCast message handlers


void BroadCast::OnBnClickedSendBroad()
{
	UpdateData(TRUE);
	if(mBroadStr.GetLength()>0)
	{
		string sx=EncodeUtf8(mBroadStr.GetBuffer());
		ChatClient::Instance()->BroadCast(sx.c_str(),nullptr);
		mBroadStr.ReleaseBuffer();
		mBroadStr=L"";
		UpdateData(FALSE);
		//mBroad.SetSel(-1,-1);
		//mBroad.ReplaceSel(mBroadStr);
	}
}
